package com.web.dao;

import com.web.controller.web.MskBuyOrderController;
import com.web.controller.web.WebCarouselController;
import com.web.entity.MskBuyOrder;
import io.netty.handler.codec.socks.SocksRequestType;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.type.JdbcType;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class MskBuyOrderSqlProvider {


    public String insertSelective(MskBuyOrder record) {
        BEGIN();
        INSERT_INTO("t_msk_buy_order");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }

        if (record.getCorePoints() != null) {
            VALUES("core_points", "#{corePoints,jdbcType=DECIMAL}");
        }

        if (record.getDealTime() != null) {
            VALUES("deal_time", "#{dealTime,jdbcType=TIMESTAMP}");
        }

        if (record.getDealPrice() != null) {
            VALUES("deal_price", "#{dealPrice,jdbcType=DECIMAL}");
        }

        if (record.getDealNum() != null) {
            VALUES("deal_num", "#{dealNum,jdbcType=INTEGER}");
        }

        if (record.getStatus() != null) {
            VALUES("status", "#{status,jdbcType=INTEGER}");
        }

        if (record.getIsFirst() != null) {
            VALUES("is_first", "#{isFirst,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(MskBuyOrder record) {
        BEGIN();
        UPDATE("t_msk_buy_order");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getCorePoints() != null) {
            SET("core_points = #{corePoints,jdbcType=DECIMAL}");
        }

        if (record.getDealTime() != null) {
            SET("deal_time = #{dealTime,jdbcType=TIMESTAMP}");
        }

        if (record.getDealPrice() != null) {
            SET("deal_price = #{dealPrice,jdbcType=DECIMAL}");
        }

        if (record.getDealNum() != null) {
            SET("deal_num = #{dealNum,jdbcType=INTEGER}");
        }

        if (record.getStatus() != null) {
            SET("status = #{status,jdbcType=INTEGER}");
        }

        if (record.getIsFirst() != null) {
            SET("is_first = #{isFirst,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }




    public String selectAllMskBuyOrder(MskBuyOrderController.MskBuyColumns record) {
        BEGIN();
        SELECT("id");
        SELECT("m_id");
        SELECT("name");
        SELECT("phone");
        SELECT("core_points");
        SELECT("deal_time");
        SELECT("deal_price");
        SELECT("deal_num");
        SELECT("status");
        SELECT("is_first");
        SELECT("create_time");
        SELECT("modify_time");
        FROM("t_msk_buy_order");
        if (record.getName() != null&&!"".equals(record.getName())) {
            WHERE("name = #{name,jdbcType=VARCHAR}");
        }
        if (record.getStatus() != null&&!"".equals(record.getStatus())) {
            WHERE("status = #{status,jdbcType=INTEGER}");
        }
        if (record.getPhone() != null&&!"".equals(record.getPhone())) {
            WHERE("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getIsFirst() != null&&!"".equals(record.getIsFirst())) {
            WHERE("is_first = #{isFirst,jdbcType=INTEGER}");
        }

        ORDER_BY("create_time desc") ;

        return SQL();
    }

}